﻿namespace ExamV5.CardInfo
{
    using ExamV5;
    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class FrmSetCardInfo : Page
    {
        protected Button butDefault;
        protected HtmlForm Form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        private PublicFun publicFun_0 = new PublicFun();
        protected RadioButtonList RBLPrintCardNum;
        protected RadioButtonList RBLPrintLotDate;
        protected TextBox txtCardDate;
        protected TextBox txtCardFen;
        protected TextBox txtCardGDH;
        protected TextBox txtCardNumber;
        protected TextBox txtUnitName;

        protected void butDefault_Click(object sender, EventArgs e)
        {
            try
            {
                Convert.ToInt32(this.txtCardNumber.Text);
            }
            catch
            {
                base.Response.Write("<script>alert('证书编号流水号不正确！')</script>");
                return;
            }
            try
            {
                Convert.ToInt32(this.txtCardDate.Text);
            }
            catch
            {
                base.Response.Write("<script>alert('证书有效期限不正确！')</script>");
                return;
            }
            try
            {
                Convert.ToDouble(this.txtCardFen.Text);
            }
            catch
            {
                base.Response.Write("<script>alert('合格分值标准不正确！')</script>");
                return;
            }
            string strSql = "";
            strSql = ((((("update SysparmInfo set ParmName='" + this.publicFun_0.CheckString(this.txtCardGDH.Text) + "',ParmValue='" + this.publicFun_0.CheckString(this.txtCardNumber.Text) + "' where ParmMemo='CardInfo';") + "update SysparmInfo set ParmValue='" + this.publicFun_0.CheckString(this.txtCardDate.Text) + "' where ParmMemo='CardDate';") + "update SysparmInfo set ParmValue='" + this.publicFun_0.CheckString(this.txtCardFen.Text) + "' where ParmMemo='CardFen';") + "update SysparmInfo set ParmValue='" + this.publicFun_0.CheckString(this.txtUnitName.Text) + "' where ParmMemo='CardSendUnit';") + "update SysparmInfo set ParmValue='" + this.publicFun_0.CheckString(this.RBLPrintLotDate.SelectedItem.Value) + "' where ParmMemo='CardLotDate';") + "update SysparmInfo set ParmValue='" + this.publicFun_0.CheckString(this.RBLPrintCardNum.SelectedItem.Value) + "' where ParmMemo='CardSFZH'";
            this.publicFun_0.ExecuteSql(strSql);
            base.Response.Write("<script>alert('设置证书参数操作成功！')</script>");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_2 = new HttpCookie("ExamUserLevel");
            this.httpCookie_2 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_3 = new HttpCookie("ExamDeptID");
            this.httpCookie_3 = base.Request.Cookies["ExamDeptID"];
            if ((this.httpCookie_0 != null) ? !(this.httpCookie_0.Value == "") : false)
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                if (!base.IsPostBack)
                {
                    if (this.httpCookie_2.Value == "A")
                    {
                        base.Response.Write("<script>alert('证书权限未开放！')</script>");
                    }
                    else
                    {
                        this.txtCardGDH.Text = this.publicFun_0.GetValues("select ParmName from SysParmInfo where ParmMemo='CardInfo'", "ParmName");
                        this.txtCardNumber.Text = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='CardInfo'", "ParmValue");
                        this.txtCardDate.Text = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='CardDate'", "ParmValue");
                        this.txtCardFen.Text = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='CardFen'", "ParmValue");
                        this.txtUnitName.Text = this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='CardSendUnit'", "ParmValue");
                        this.RBLPrintLotDate.SelectedIndex = -1;
                        this.RBLPrintCardNum.SelectedIndex = -1;
                        this.RBLPrintLotDate.Items.FindByValue(this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='CardLotDate'", "ParmValue")).Selected = true;
                        this.RBLPrintCardNum.Items.FindByValue(this.publicFun_0.GetValues("select ParmValue from SysParmInfo where ParmMemo='CardSFZH'", "ParmValue")).Selected = true;
                    }
                }
            }
            else
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
        }
    }
}

